/**
 * 数据字典
 */

import { reactive } from 'vue'

const ddo = {

	refresh: true,//是否刷新

	text(mark, code) {
		const option = this[mark].find(item => item.value === code);
		return option ? option.label : '';
	},
	homeConatiner:null,
	gotoHomeTop(){
		if(this.homeConatiner){
			this.homeConatiner.scrollTo(0,0);
		}
	},
	// 当前用户信息
	currentUser: [
	],
	currentImageUrl:"",
	//性别
	sex: [{
		value: 1,
		label: '男'
	}, {
		value: 2,
		label: '女'
	}],

	// 动漫分类
	animeType: [{
		value: 0,
		label: '原创'
	}, {
		value: 1,
		label: '漫改'
	}, {
		value: 2,
		label: '轻改'
	}, {
		value: 3,
		label: '游戏改'
	}, {
		value: 4,
		label: '其他'
	}],

	// 帖子类型
	postType: [{
		value: 0,
		label: '番剧贴'
	}, {
		value: 1,
		label: '主题贴'
	}, {
		value: 2,
		label: '回复贴'
	}, {
		value: 3,
		label: '漫评贴'
	}],


	// 回复贴的类型
	replyType: [{ 
		value: 1, label: '主题帖的回复' 
	}, {
		value: 2, label: '漫评贴的回复'
	}, {
		value: 3, label: '回复的回复'
	}],

	// 是否加精
	isGood: [{
		value: 1, label: '已加精'
	}, {
		value: 0, label: '未加精'
	}],
	
	// 是否隐藏
	isHidden: [{
		value: 1, label: '已隐藏'
	}, {
		value: 0, label: '未隐藏'
	}],

	// 是否锁定
	isLocked: [{
		value: 1, label: '已锁定'
	}, {
		value: 0, label: '未锁定'
	}],
	
	// 颜色
	color:{
		DustRed  : ['#fff1f0', '#ffccc7', '#ffa39e', '#ff7875' ,'#ff4d4f' ,'#f5222d', '#cf1322', '#a8071a', '#820014', '#5c0011'],
		Volcano  : ['#fff2e8', '#ffd8bf', '#ffbb96', '#ff9c6e', '#ff7a45', '#fa541c', '#d4380d', '#ad2102', '#871400', '#610b00'],
		Sunset   : ['#fff7e6', '#ffe7ba', '#ffd591', '#ffc069', '#ffa940', '#fa8c16', '#d46b08', '#ad4e00', '#873800', '#612500'],
		Calendula: ['#fffbe6', '#fff1b8', '#ffe58f', '#ffd666', '#ffc53d', '#faad14', '#d48806', '#ad6800', '#874d00', '#613400'],
		Sunrise  : ['#feffe6', '#ffffb8', '#fffb8f', '#fff566', '#ffec3d', '#fadb14', '#d4b106', '#ad8b00', '#876800', '#614700'],
		Lime     : ['#fcffe6', '#f4ffb8', '#eaff8f', '#d3f261', '#bae637', '#a0d911', '#7cb305', '#5b8c00', '#3f6600', '#254000'],
		PolarGreen: [],
		Cyan: [],
		Daybreak:[],
		Geek: [],
		Purple:[],
		Megenta:[]
	},
	
	getTitleString(codeString, delimiter) {
		if (codeString && (codeString instanceof String || typeof codeString === 'string')) {
			const arr = codeString.split(delimiter || ',');
			return this.title.filter(item => arr.some(code => Number(code) == item.value)).map(item => item.label).join(delimiter || ',');
		}
		return '';
	},

	edu: [
		{ value: 1, label: '高中/中专' },
		{ value: 2, label: '专科' },
		{ value: 3, label: '本科' },
		{ value: 4, label: '硕士' },
		{ value: 5, label: '博士' }
	],

	//初始化字典数据，forced表示是否强制从服务器获取最新数据
	init(forced) {

		if (this.refresh || forced) {

			//在这里可以加入初始化逻辑

			this.refresh = false;
		}

	}

};

ddo.init();

export default reactive(ddo);
